package com.med.meddataintegrator.admin.controller;

import com.med.meddataintegrator.admin.base.response.JsonResult;
import com.med.meddataintegrator.admin.service.AppointmentService;
import com.med.meddataintegrator.common.pojo.dos.AppointmentDo;
import com.med.meddataintegrator.common.pojo.dto.Appointment.ApplicationQuery;
import com.med.meddataintegrator.common.pojo.dto.Appointment.ApplicationUpdateParam;
import com.med.meddataintegrator.common.pojo.dto.Appointment.AppointmentAddParam;
import com.med.meddataintegrator.common.pojo.vo.appointment.AppointmentVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin/appointment")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;
    @PostMapping("add")
    public JsonResult add(@RequestBody AppointmentAddParam appointmentAddParam){
        log.debug("添加预约信息", appointmentAddParam);
        appointmentService.add(appointmentAddParam);
        return JsonResult.ok();
    }
    @PostMapping("del/{id}")
    public JsonResult delete(@PathVariable Integer id){
        log.debug("删除预约信息", id);
        appointmentService.delete(id);
        return JsonResult.ok();
    }
    @PostMapping("update")
    public JsonResult update(@RequestBody ApplicationUpdateParam applicationUpdateParam){
        log.debug("更新预约信息", applicationUpdateParam);
        appointmentService.update(applicationUpdateParam);
        return JsonResult.ok();
    }
    @GetMapping("list")
    public  JsonResult list(ApplicationQuery applicationQuery){
        log.debug("查询预约信息", applicationQuery);
        List<AppointmentVo> list = appointmentService.list(applicationQuery);
        return JsonResult.ok(list);
    }
}
